<?php
//升级数据表
pdo_query("CREATE TABLE IF NOT EXISTS `ims_tim_welfare_adv` (
  `adv_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `uniacid` int(11) NOT NULL,
  `adv_title` varchar(100) DEFAULT NULL,
  `adv_pic` varchar(200) DEFAULT NULL,
  `adv_link` varchar(200) DEFAULT NULL,
  `position` tinyint(2) NOT NULL DEFAULT '0',
  PRIMARY KEY (`adv_id`)
) ENGINE=MyISAM AUTO_INCREMENT=8 DEFAULT CHARSET=utf8;

");

if(!pdo_fieldexists('tim_welfare_adv','adv_id')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_adv')." ADD 
  `adv_id` int(10) unsigned NOT NULL AUTO_INCREMENT");}
if(!pdo_fieldexists('tim_welfare_adv','uniacid')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_adv')." ADD   `uniacid` int(11) NOT NULL");}
if(!pdo_fieldexists('tim_welfare_adv','adv_title')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_adv')." ADD   `adv_title` varchar(100) DEFAULT NULL");}
if(!pdo_fieldexists('tim_welfare_adv','adv_pic')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_adv')." ADD   `adv_pic` varchar(200) DEFAULT NULL");}
if(!pdo_fieldexists('tim_welfare_adv','adv_link')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_adv')." ADD   `adv_link` varchar(200) DEFAULT NULL");}
if(!pdo_fieldexists('tim_welfare_adv','position')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_adv')." ADD   `position` tinyint(2) NOT NULL DEFAULT '0'");}
pdo_query("CREATE TABLE IF NOT EXISTS `ims_tim_welfare_article` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `uniacid` int(11) NOT NULL,
  `title` varchar(255) DEFAULT NULL,
  `images` varchar(255) DEFAULT NULL,
  `short` varchar(255) DEFAULT NULL,
  `content` text,
  `is_stick` int(1) DEFAULT NULL,
  `add_time` int(11) DEFAULT '0',
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

");

if(!pdo_fieldexists('tim_welfare_article','id')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_article')." ADD 
  `id` int(11) NOT NULL AUTO_INCREMENT");}
if(!pdo_fieldexists('tim_welfare_article','uniacid')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_article')." ADD   `uniacid` int(11) NOT NULL");}
if(!pdo_fieldexists('tim_welfare_article','title')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_article')." ADD   `title` varchar(255) DEFAULT NULL");}
if(!pdo_fieldexists('tim_welfare_article','images')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_article')." ADD   `images` varchar(255) DEFAULT NULL");}
if(!pdo_fieldexists('tim_welfare_article','short')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_article')." ADD   `short` varchar(255) DEFAULT NULL");}
if(!pdo_fieldexists('tim_welfare_article','content')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_article')." ADD   `content` text");}
if(!pdo_fieldexists('tim_welfare_article','is_stick')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_article')." ADD   `is_stick` int(1) DEFAULT NULL");}
if(!pdo_fieldexists('tim_welfare_article','add_time')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_article')." ADD   `add_time` int(11) DEFAULT '0'");}
pdo_query("CREATE TABLE IF NOT EXISTS `ims_tim_welfare_class` (
  `class_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `uniacid` int(11) NOT NULL,
  `class_name` varchar(40) NOT NULL,
  PRIMARY KEY (`class_id`)
) ENGINE=MyISAM AUTO_INCREMENT=54 DEFAULT CHARSET=utf8;

");

if(!pdo_fieldexists('tim_welfare_class','class_id')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_class')." ADD 
  `class_id` int(10) unsigned NOT NULL AUTO_INCREMENT");}
if(!pdo_fieldexists('tim_welfare_class','uniacid')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_class')." ADD   `uniacid` int(11) NOT NULL");}
if(!pdo_fieldexists('tim_welfare_class','class_name')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_class')." ADD   `class_name` varchar(40) NOT NULL");}
pdo_query("CREATE TABLE IF NOT EXISTS `ims_tim_welfare_comment` (
  `comment_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `parent_id` int(10) unsigned NOT NULL DEFAULT '0',
  `pro_id` int(10) DEFAULT NULL,
  `mem_id` int(10) DEFAULT NULL,
  `comment_cont` varchar(400) DEFAULT NULL,
  `time` int(10) DEFAULT NULL,
  `state` int(1) DEFAULT '0',
  PRIMARY KEY (`comment_id`),
  KEY `mem_id` (`mem_id`),
  KEY `pro_id` (`pro_id`)
) ENGINE=MyISAM AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;

");

if(!pdo_fieldexists('tim_welfare_comment','comment_id')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_comment')." ADD 
  `comment_id` int(10) unsigned NOT NULL AUTO_INCREMENT");}
if(!pdo_fieldexists('tim_welfare_comment','parent_id')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_comment')." ADD   `parent_id` int(10) unsigned NOT NULL DEFAULT '0'");}
if(!pdo_fieldexists('tim_welfare_comment','pro_id')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_comment')." ADD   `pro_id` int(10) DEFAULT NULL");}
if(!pdo_fieldexists('tim_welfare_comment','mem_id')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_comment')." ADD   `mem_id` int(10) DEFAULT NULL");}
if(!pdo_fieldexists('tim_welfare_comment','comment_cont')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_comment')." ADD   `comment_cont` varchar(400) DEFAULT NULL");}
if(!pdo_fieldexists('tim_welfare_comment','time')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_comment')." ADD   `time` int(10) DEFAULT NULL");}
if(!pdo_fieldexists('tim_welfare_comment','state')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_comment')." ADD   `state` int(1) DEFAULT '0'");}
if(!pdo_fieldexists('tim_welfare_comment','comment_id')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_comment')." ADD   PRIMARY KEY (`comment_id`)");}
if(!pdo_fieldexists('tim_welfare_comment','mem_id')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_comment')." ADD   KEY `mem_id` (`mem_id`)");}
pdo_query("CREATE TABLE IF NOT EXISTS `ims_tim_welfare_company` (
  `company_id` int(11) NOT NULL AUTO_INCREMENT,
  `uniacid` int(11) NOT NULL,
  `company_name` varchar(255) DEFAULT NULL,
  `name` varchar(255) DEFAULT NULL,
  `phone` varchar(255) DEFAULT NULL,
  `content` text,
  `company_img` varchar(255) DEFAULT NULL,
  `add_time` int(11) DEFAULT '0',
  PRIMARY KEY (`company_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

");

if(!pdo_fieldexists('tim_welfare_company','company_id')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_company')." ADD 
  `company_id` int(11) NOT NULL AUTO_INCREMENT");}
if(!pdo_fieldexists('tim_welfare_company','uniacid')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_company')." ADD   `uniacid` int(11) NOT NULL");}
if(!pdo_fieldexists('tim_welfare_company','company_name')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_company')." ADD   `company_name` varchar(255) DEFAULT NULL");}
if(!pdo_fieldexists('tim_welfare_company','name')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_company')." ADD   `name` varchar(255) DEFAULT NULL");}
if(!pdo_fieldexists('tim_welfare_company','phone')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_company')." ADD   `phone` varchar(255) DEFAULT NULL");}
if(!pdo_fieldexists('tim_welfare_company','content')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_company')." ADD   `content` text");}
if(!pdo_fieldexists('tim_welfare_company','company_img')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_company')." ADD   `company_img` varchar(255) DEFAULT NULL");}
if(!pdo_fieldexists('tim_welfare_company','add_time')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_company')." ADD   `add_time` int(11) DEFAULT '0'");}
pdo_query("CREATE TABLE IF NOT EXISTS `ims_tim_welfare_custom` (
  `id` int(1) NOT NULL AUTO_INCREMENT,
  `uniacid` int(11) NOT NULL,
  `name` varchar(100) DEFAULT NULL,
  `photo` varchar(255) DEFAULT NULL,
  `ewm` varchar(255) DEFAULT NULL,
  `logo` varchar(255) DEFAULT NULL,
  `content1` varchar(255) DEFAULT NULL,
  `content2` text,
  `content3` varchar(255) DEFAULT NULL,
  `add_time` int(11) DEFAULT '0',
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

");

if(!pdo_fieldexists('tim_welfare_custom','id')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_custom')." ADD 
  `id` int(1) NOT NULL AUTO_INCREMENT");}
if(!pdo_fieldexists('tim_welfare_custom','uniacid')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_custom')." ADD   `uniacid` int(11) NOT NULL");}
if(!pdo_fieldexists('tim_welfare_custom','name')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_custom')." ADD   `name` varchar(100) DEFAULT NULL");}
if(!pdo_fieldexists('tim_welfare_custom','photo')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_custom')." ADD   `photo` varchar(255) DEFAULT NULL");}
if(!pdo_fieldexists('tim_welfare_custom','ewm')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_custom')." ADD   `ewm` varchar(255) DEFAULT NULL");}
if(!pdo_fieldexists('tim_welfare_custom','logo')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_custom')." ADD   `logo` varchar(255) DEFAULT NULL");}
if(!pdo_fieldexists('tim_welfare_custom','content1')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_custom')." ADD   `content1` varchar(255) DEFAULT NULL");}
if(!pdo_fieldexists('tim_welfare_custom','content2')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_custom')." ADD   `content2` text");}
if(!pdo_fieldexists('tim_welfare_custom','content3')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_custom')." ADD   `content3` varchar(255) DEFAULT NULL");}
if(!pdo_fieldexists('tim_welfare_custom','add_time')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_custom')." ADD   `add_time` int(11) DEFAULT '0'");}
pdo_query("CREATE TABLE IF NOT EXISTS `ims_tim_welfare_fund` (
  `fund_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `mem_id` int(10) DEFAULT NULL,
  `pro_id` int(10) DEFAULT NULL,
  `fund_value` double DEFAULT NULL,
  `fund_time` int(10) DEFAULT NULL,
  `fund_true` tinyint(2) NOT NULL DEFAULT '0',
  `order_num` varchar(100) DEFAULT NULL,
  `type` varchar(10) DEFAULT NULL COMMENT 'MONEY, CREDIT',
  PRIMARY KEY (`fund_id`),
  KEY `mem_id` (`mem_id`),
  KEY `pro_id` (`pro_id`)
) ENGINE=MyISAM AUTO_INCREMENT=77 DEFAULT CHARSET=utf8;

");

if(!pdo_fieldexists('tim_welfare_fund','fund_id')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_fund')." ADD 
  `fund_id` int(10) unsigned NOT NULL AUTO_INCREMENT");}
if(!pdo_fieldexists('tim_welfare_fund','mem_id')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_fund')." ADD   `mem_id` int(10) DEFAULT NULL");}
if(!pdo_fieldexists('tim_welfare_fund','pro_id')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_fund')." ADD   `pro_id` int(10) DEFAULT NULL");}
if(!pdo_fieldexists('tim_welfare_fund','fund_value')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_fund')." ADD   `fund_value` double DEFAULT NULL");}
if(!pdo_fieldexists('tim_welfare_fund','fund_time')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_fund')." ADD   `fund_time` int(10) DEFAULT NULL");}
if(!pdo_fieldexists('tim_welfare_fund','fund_true')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_fund')." ADD   `fund_true` tinyint(2) NOT NULL DEFAULT '0'");}
if(!pdo_fieldexists('tim_welfare_fund','order_num')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_fund')." ADD   `order_num` varchar(100) DEFAULT NULL");}
if(!pdo_fieldexists('tim_welfare_fund','type')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_fund')." ADD   `type` varchar(10) DEFAULT NULL COMMENT 'MONEY, CREDIT'");}
if(!pdo_fieldexists('tim_welfare_fund','fund_id')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_fund')." ADD   PRIMARY KEY (`fund_id`)");}
if(!pdo_fieldexists('tim_welfare_fund','mem_id')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_fund')." ADD   KEY `mem_id` (`mem_id`)");}
pdo_query("CREATE TABLE IF NOT EXISTS `ims_tim_welfare_good` (
  `goods_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `uniacid` int(11) NOT NULL,
  `goods_class` varchar(20) DEFAULT NULL,
  `goods_name` varchar(100) NOT NULL,
  `goods_pic` varchar(200) DEFAULT NULL,
  `goods_intro` text,
  `goods_param` text,
  `goods_say` text,
  `goods_price` float(10,2) DEFAULT NULL,
  `goods_status` int(2) DEFAULT NULL,
  PRIMARY KEY (`goods_id`)
) ENGINE=MyISAM AUTO_INCREMENT=10 DEFAULT CHARSET=utf8;

");

if(!pdo_fieldexists('tim_welfare_good','goods_id')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_good')." ADD 
  `goods_id` int(10) unsigned NOT NULL AUTO_INCREMENT");}
if(!pdo_fieldexists('tim_welfare_good','uniacid')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_good')." ADD   `uniacid` int(11) NOT NULL");}
if(!pdo_fieldexists('tim_welfare_good','goods_class')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_good')." ADD   `goods_class` varchar(20) DEFAULT NULL");}
if(!pdo_fieldexists('tim_welfare_good','goods_name')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_good')." ADD   `goods_name` varchar(100) NOT NULL");}
if(!pdo_fieldexists('tim_welfare_good','goods_pic')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_good')." ADD   `goods_pic` varchar(200) DEFAULT NULL");}
if(!pdo_fieldexists('tim_welfare_good','goods_intro')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_good')." ADD   `goods_intro` text");}
if(!pdo_fieldexists('tim_welfare_good','goods_param')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_good')." ADD   `goods_param` text");}
if(!pdo_fieldexists('tim_welfare_good','goods_say')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_good')." ADD   `goods_say` text");}
if(!pdo_fieldexists('tim_welfare_good','goods_price')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_good')." ADD   `goods_price` float(10,2) DEFAULT NULL");}
if(!pdo_fieldexists('tim_welfare_good','goods_status')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_good')." ADD   `goods_status` int(2) DEFAULT NULL");}
pdo_query("CREATE TABLE IF NOT EXISTS `ims_tim_welfare_mall` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `uniacid` int(11) NOT NULL,
  `copyright` varchar(200) DEFAULT NULL,
  `code_pic` varchar(200) DEFAULT NULL,
  `banner` varchar(200) DEFAULT NULL,
  `banner_link` varchar(200) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=14 DEFAULT CHARSET=utf8;

");

if(!pdo_fieldexists('tim_welfare_mall','id')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_mall')." ADD 
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT");}
if(!pdo_fieldexists('tim_welfare_mall','uniacid')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_mall')." ADD   `uniacid` int(11) NOT NULL");}
if(!pdo_fieldexists('tim_welfare_mall','copyright')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_mall')." ADD   `copyright` varchar(200) DEFAULT NULL");}
if(!pdo_fieldexists('tim_welfare_mall','code_pic')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_mall')." ADD   `code_pic` varchar(200) DEFAULT NULL");}
if(!pdo_fieldexists('tim_welfare_mall','banner')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_mall')." ADD   `banner` varchar(200) DEFAULT NULL");}
if(!pdo_fieldexists('tim_welfare_mall','banner_link')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_mall')." ADD   `banner_link` varchar(200) DEFAULT NULL");}
pdo_query("CREATE TABLE IF NOT EXISTS `ims_tim_welfare_member` (
  `mem_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `mem_name` varchar(100) DEFAULT NULL,
  `mem_photo` varchar(200) DEFAULT NULL,
  `mem_pass` varchar(200) DEFAULT NULL,
  `openid` varchar(200) NOT NULL,
  `uniacid` int(10) NOT NULL,
  PRIMARY KEY (`mem_id`)
) ENGINE=MyISAM AUTO_INCREMENT=154 DEFAULT CHARSET=utf8;

");

if(!pdo_fieldexists('tim_welfare_member','mem_id')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_member')." ADD 
  `mem_id` int(10) unsigned NOT NULL AUTO_INCREMENT");}
if(!pdo_fieldexists('tim_welfare_member','mem_name')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_member')." ADD   `mem_name` varchar(100) DEFAULT NULL");}
if(!pdo_fieldexists('tim_welfare_member','mem_photo')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_member')." ADD   `mem_photo` varchar(200) DEFAULT NULL");}
if(!pdo_fieldexists('tim_welfare_member','mem_pass')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_member')." ADD   `mem_pass` varchar(200) DEFAULT NULL");}
if(!pdo_fieldexists('tim_welfare_member','openid')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_member')." ADD   `openid` varchar(200) NOT NULL");}
if(!pdo_fieldexists('tim_welfare_member','uniacid')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_member')." ADD   `uniacid` int(10) NOT NULL");}
pdo_query("CREATE TABLE IF NOT EXISTS `ims_tim_welfare_order` (
  `order_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `order_num` varchar(100) DEFAULT NULL,
  `mem_id` int(10) NOT NULL,
  `goods_id` int(10) NOT NULL,
  `pro_id` int(10) NOT NULL,
  `address` varchar(100) DEFAULT NULL,
  `goods_num` int(2) DEFAULT NULL,
  `total_price` float(10,2) DEFAULT NULL,
  `status` int(1) DEFAULT NULL,
  `createtime` int(10) DEFAULT '0',
  PRIMARY KEY (`order_id`),
  KEY `mem_id` (`mem_id`),
  KEY `goods_id` (`goods_id`),
  KEY `pro_id` (`pro_id`)
) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;

");

if(!pdo_fieldexists('tim_welfare_order','order_id')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_order')." ADD 
  `order_id` int(10) unsigned NOT NULL AUTO_INCREMENT");}
if(!pdo_fieldexists('tim_welfare_order','order_num')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_order')." ADD   `order_num` varchar(100) DEFAULT NULL");}
if(!pdo_fieldexists('tim_welfare_order','mem_id')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_order')." ADD   `mem_id` int(10) NOT NULL");}
if(!pdo_fieldexists('tim_welfare_order','goods_id')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_order')." ADD   `goods_id` int(10) NOT NULL");}
if(!pdo_fieldexists('tim_welfare_order','pro_id')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_order')." ADD   `pro_id` int(10) NOT NULL");}
if(!pdo_fieldexists('tim_welfare_order','address')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_order')." ADD   `address` varchar(100) DEFAULT NULL");}
if(!pdo_fieldexists('tim_welfare_order','goods_num')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_order')." ADD   `goods_num` int(2) DEFAULT NULL");}
if(!pdo_fieldexists('tim_welfare_order','total_price')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_order')." ADD   `total_price` float(10,2) DEFAULT NULL");}
if(!pdo_fieldexists('tim_welfare_order','status')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_order')." ADD   `status` int(1) DEFAULT NULL");}
if(!pdo_fieldexists('tim_welfare_order','createtime')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_order')." ADD   `createtime` int(10) DEFAULT '0'");}
if(!pdo_fieldexists('tim_welfare_order','order_id')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_order')." ADD   PRIMARY KEY (`order_id`)");}
if(!pdo_fieldexists('tim_welfare_order','mem_id')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_order')." ADD   KEY `mem_id` (`mem_id`)");}
if(!pdo_fieldexists('tim_welfare_order','goods_id')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_order')." ADD   KEY `goods_id` (`goods_id`)");}
pdo_query("CREATE TABLE IF NOT EXISTS `ims_tim_welfare_project` (
  `pro_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `uniacid` int(11) NOT NULL,
  `class_id` int(10) DEFAULT NULL,
  `pro_name` varchar(40) NOT NULL,
  `pro_short` varchar(100) DEFAULT NULL,
  `pro_gress` text,
  `pro_feature` varchar(200) DEFAULT NULL,
  `pro_content` text,
  `pro_fund` double DEFAULT NULL,
  `pro_goal` float DEFAULT NULL,
  `pro_stick` tinyint(2) NOT NULL DEFAULT '0',
  `starttime` int(10) DEFAULT NULL,
  `endtime` int(10) DEFAULT NULL,
  `company_id` int(10) DEFAULT NULL,
  `pro_uber` int(1) DEFAULT NULL,
  PRIMARY KEY (`pro_id`),
  KEY `class_id` (`class_id`)
) ENGINE=MyISAM AUTO_INCREMENT=23 DEFAULT CHARSET=utf8;

");

if(!pdo_fieldexists('tim_welfare_project','pro_id')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_project')." ADD 
  `pro_id` int(10) unsigned NOT NULL AUTO_INCREMENT");}
if(!pdo_fieldexists('tim_welfare_project','uniacid')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_project')." ADD   `uniacid` int(11) NOT NULL");}
if(!pdo_fieldexists('tim_welfare_project','class_id')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_project')." ADD   `class_id` int(10) DEFAULT NULL");}
if(!pdo_fieldexists('tim_welfare_project','pro_name')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_project')." ADD   `pro_name` varchar(40) NOT NULL");}
if(!pdo_fieldexists('tim_welfare_project','pro_short')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_project')." ADD   `pro_short` varchar(100) DEFAULT NULL");}
if(!pdo_fieldexists('tim_welfare_project','pro_gress')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_project')." ADD   `pro_gress` text");}
if(!pdo_fieldexists('tim_welfare_project','pro_feature')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_project')." ADD   `pro_feature` varchar(200) DEFAULT NULL");}
if(!pdo_fieldexists('tim_welfare_project','pro_content')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_project')." ADD   `pro_content` text");}
if(!pdo_fieldexists('tim_welfare_project','pro_fund')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_project')." ADD   `pro_fund` double DEFAULT NULL");}
if(!pdo_fieldexists('tim_welfare_project','pro_goal')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_project')." ADD   `pro_goal` float DEFAULT NULL");}
if(!pdo_fieldexists('tim_welfare_project','pro_stick')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_project')." ADD   `pro_stick` tinyint(2) NOT NULL DEFAULT '0'");}
if(!pdo_fieldexists('tim_welfare_project','starttime')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_project')." ADD   `starttime` int(10) DEFAULT NULL");}
if(!pdo_fieldexists('tim_welfare_project','endtime')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_project')." ADD   `endtime` int(10) DEFAULT NULL");}
if(!pdo_fieldexists('tim_welfare_project','company_id')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_project')." ADD   `company_id` int(10) DEFAULT NULL");}
if(!pdo_fieldexists('tim_welfare_project','pro_uber')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_project')." ADD   `pro_uber` int(1) DEFAULT NULL");}
if(!pdo_fieldexists('tim_welfare_project','pro_id')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_project')." ADD   PRIMARY KEY (`pro_id`)");}
pdo_query("CREATE TABLE IF NOT EXISTS `ims_tim_welfare_set` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `uniacid` int(11) NOT NULL,
  `gy_name` varchar(40) DEFAULT NULL,
  `gy_logo` varchar(100) DEFAULT NULL,
  `follow_url` varchar(200) DEFAULT NULL,
  `gy_agree_name` varchar(100) DEFAULT NULL,
  `gy_agree` text,
  `appid` varchar(200) NOT NULL,
  `appsecret` varchar(200) NOT NULL,
  `mchid` varchar(100) NOT NULL,
  `shkey` varchar(100) NOT NULL,
  `is_follow` tinyint(2) NOT NULL DEFAULT '0',
  `is_sort` tinyint(2) NOT NULL DEFAULT '0',
  `type` varchar(10) NOT NULL DEFAULT 'MONEY' COMMENT 'MONEY, CREDIT, MIXTURE',
  `ratio` int(10) DEFAULT NULL,
  `template_id` varchar(100) DEFAULT NULL,
  `cash1` varchar(50) DEFAULT NULL,
  `cash2` varchar(50) DEFAULT NULL,
  `cash3` varchar(50) DEFAULT NULL,
  `cash4` varchar(50) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=18 DEFAULT CHARSET=utf8;

");

if(!pdo_fieldexists('tim_welfare_set','id')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_set')." ADD 
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT");}
if(!pdo_fieldexists('tim_welfare_set','uniacid')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_set')." ADD   `uniacid` int(11) NOT NULL");}
if(!pdo_fieldexists('tim_welfare_set','gy_name')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_set')." ADD   `gy_name` varchar(40) DEFAULT NULL");}
if(!pdo_fieldexists('tim_welfare_set','gy_logo')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_set')." ADD   `gy_logo` varchar(100) DEFAULT NULL");}
if(!pdo_fieldexists('tim_welfare_set','follow_url')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_set')." ADD   `follow_url` varchar(200) DEFAULT NULL");}
if(!pdo_fieldexists('tim_welfare_set','gy_agree_name')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_set')." ADD   `gy_agree_name` varchar(100) DEFAULT NULL");}
if(!pdo_fieldexists('tim_welfare_set','gy_agree')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_set')." ADD   `gy_agree` text");}
if(!pdo_fieldexists('tim_welfare_set','appid')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_set')." ADD   `appid` varchar(200) NOT NULL");}
if(!pdo_fieldexists('tim_welfare_set','appsecret')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_set')." ADD   `appsecret` varchar(200) NOT NULL");}
if(!pdo_fieldexists('tim_welfare_set','mchid')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_set')." ADD   `mchid` varchar(100) NOT NULL");}
if(!pdo_fieldexists('tim_welfare_set','shkey')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_set')." ADD   `shkey` varchar(100) NOT NULL");}
if(!pdo_fieldexists('tim_welfare_set','is_follow')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_set')." ADD   `is_follow` tinyint(2) NOT NULL DEFAULT '0'");}
if(!pdo_fieldexists('tim_welfare_set','is_sort')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_set')." ADD   `is_sort` tinyint(2) NOT NULL DEFAULT '0'");}
if(!pdo_fieldexists('tim_welfare_set','type')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_set')." ADD   `type` varchar(10) NOT NULL DEFAULT 'MONEY' COMMENT 'MONEY, CREDIT, MIXTURE'");}
if(!pdo_fieldexists('tim_welfare_set','ratio')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_set')." ADD   `ratio` int(10) DEFAULT NULL");}
if(!pdo_fieldexists('tim_welfare_set','template_id')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_set')." ADD   `template_id` varchar(100) DEFAULT NULL");}
if(!pdo_fieldexists('tim_welfare_set','cash1')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_set')." ADD   `cash1` varchar(50) DEFAULT NULL");}
if(!pdo_fieldexists('tim_welfare_set','cash2')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_set')." ADD   `cash2` varchar(50) DEFAULT NULL");}
if(!pdo_fieldexists('tim_welfare_set','cash3')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_set')." ADD   `cash3` varchar(50) DEFAULT NULL");}
if(!pdo_fieldexists('tim_welfare_set','cash4')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_set')." ADD   `cash4` varchar(50) DEFAULT NULL");}
pdo_query("CREATE TABLE IF NOT EXISTS `ims_tim_welfare_slide` (
  `slide_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `uniacid` int(11) NOT NULL,
  `slide_pic` varchar(200) DEFAULT NULL,
  `slide_title` varchar(100) DEFAULT NULL,
  `slide_url` varchar(200) DEFAULT NULL,
  `xh` int(10) DEFAULT NULL,
  PRIMARY KEY (`slide_id`)
) ENGINE=MyISAM AUTO_INCREMENT=36 DEFAULT CHARSET=utf8;

");

if(!pdo_fieldexists('tim_welfare_slide','slide_id')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_slide')." ADD 
  `slide_id` int(10) unsigned NOT NULL AUTO_INCREMENT");}
if(!pdo_fieldexists('tim_welfare_slide','uniacid')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_slide')." ADD   `uniacid` int(11) NOT NULL");}
if(!pdo_fieldexists('tim_welfare_slide','slide_pic')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_slide')." ADD   `slide_pic` varchar(200) DEFAULT NULL");}
if(!pdo_fieldexists('tim_welfare_slide','slide_title')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_slide')." ADD   `slide_title` varchar(100) DEFAULT NULL");}
if(!pdo_fieldexists('tim_welfare_slide','slide_url')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_slide')." ADD   `slide_url` varchar(200) DEFAULT NULL");}
if(!pdo_fieldexists('tim_welfare_slide','xh')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_slide')." ADD   `xh` int(10) DEFAULT NULL");}
pdo_query("CREATE TABLE IF NOT EXISTS `ims_tim_welfare_uadd` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `mem_id` int(10) DEFAULT NULL,
  `class_id` int(10) DEFAULT NULL,
  `utel` varchar(20) DEFAULT NULL,
  `pro_name` varchar(40) NOT NULL,
  `pro_short` varchar(30) DEFAULT NULL,
  `pro_gress` text,
  `pro_feature` varchar(200) DEFAULT NULL,
  `pro_content` text,
  `pro_goal` float DEFAULT NULL,
  `add_time` int(10) DEFAULT NULL,
  `verify` tinyint(2) NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `mem_id` (`mem_id`),
  KEY `class_id` (`class_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

");

if(!pdo_fieldexists('tim_welfare_uadd','id')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_uadd')." ADD 
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT");}
if(!pdo_fieldexists('tim_welfare_uadd','mem_id')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_uadd')." ADD   `mem_id` int(10) DEFAULT NULL");}
if(!pdo_fieldexists('tim_welfare_uadd','class_id')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_uadd')." ADD   `class_id` int(10) DEFAULT NULL");}
if(!pdo_fieldexists('tim_welfare_uadd','utel')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_uadd')." ADD   `utel` varchar(20) DEFAULT NULL");}
if(!pdo_fieldexists('tim_welfare_uadd','pro_name')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_uadd')." ADD   `pro_name` varchar(40) NOT NULL");}
if(!pdo_fieldexists('tim_welfare_uadd','pro_short')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_uadd')." ADD   `pro_short` varchar(30) DEFAULT NULL");}
if(!pdo_fieldexists('tim_welfare_uadd','pro_gress')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_uadd')." ADD   `pro_gress` text");}
if(!pdo_fieldexists('tim_welfare_uadd','pro_feature')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_uadd')." ADD   `pro_feature` varchar(200) DEFAULT NULL");}
if(!pdo_fieldexists('tim_welfare_uadd','pro_content')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_uadd')." ADD   `pro_content` text");}
if(!pdo_fieldexists('tim_welfare_uadd','pro_goal')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_uadd')." ADD   `pro_goal` float DEFAULT NULL");}
if(!pdo_fieldexists('tim_welfare_uadd','add_time')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_uadd')." ADD   `add_time` int(10) DEFAULT NULL");}
if(!pdo_fieldexists('tim_welfare_uadd','verify')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_uadd')." ADD   `verify` tinyint(2) NOT NULL DEFAULT '0'");}
if(!pdo_fieldexists('tim_welfare_uadd','id')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_uadd')." ADD   PRIMARY KEY (`id`)");}
if(!pdo_fieldexists('tim_welfare_uadd','mem_id')) {pdo_query("ALTER TABLE ".tablename('tim_welfare_uadd')." ADD   KEY `mem_id` (`mem_id`)");}
